from bs4 import BeautifulSoup

html_text = """<html>
    <head>
        <title>这是一个构造的测试页面</title>
    </head>
    <body>
        <div class="title">
            <b>页面标题</b>
        </div>
        <div class="story">这里给了几个网站：
			<a href="https://www.baidu.com" class="baidu index" id="link1">百度</a>,
			<a href="https://www.taobao.com" class="taobao" id="link2">淘宝</a>,
			<a href="https://www.jd.com" class="jindong" id="link3">京东</a>.
			<div>
				<a href="https://www.bilibili.com/" class="bilibili index" id="link4">哔哩哔哩</a>
			</div>
        </div>

        <p class="story">...</p>
    </body>
</html>"""

# 实例化解析对象
soup = BeautifulSoup(html_text, 'lxml')

# # 找class属性=taobao的节点,返回的是一个列表格式的可迭代对象
# my_tag = soup.select('.taobao')
# print(my_tag)
# print(type(my_tag))

# # 找id=link3节点
# my_tag = soup.select('#link3')
# print(my_tag)

# # 找所有的a节点
# a_tag = soup.select('a')
# print(a_tag)

